<!DOCTYPE HTML>
<html>

<head>
  <title>系统参数</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <!-- <link href="../assets/css/dpl-min.css" rel="stylesheet" type="text/css" /> -->
  <!--<link href="../assets/css/bui-min.css" rel="stylesheet" type="text/css" />-->
  <!--<link href="../assets/css/page-min.css" rel="stylesheet" type="text/css" />-->
  <!--<link href="../assets/css/prettify.css" rel="stylesheet" type="text/css" />-->
  <!--<link rel="stylesheet" href="../boostrap/css/bootstrap.css" />-->

  <link href="/static/assets/css/bui-min.css" rel="stylesheet" type="text/css"/>
  <link href="/static/assets/css/page-min.css" rel="stylesheet" type="text/css"/>
  <link href="/static/assets/css/prettify.css" rel="stylesheet" type="text/css"/>
  <link rel="stylesheet" href="/static/bootstrap/css/bootstrap.css"/>


  <style type="text/css">
      body{
           background: #EFF3FC;
      }
    html,
    body,
    .container {
      height: 100%;
    }
    label {
      font-weight: normal;
    }
    .container {
      font-size: 14px;
      margin-left: 0;
      margin-top: 0;
      width: auto;
      padding: 0px 20px 0 20px;
    }

    .container-title {
      padding: 15px 15px;
    }

    .title-border {
      border-bottom: 1px solid rgba(242, 242, 242, 1);
    }

    .form-label {
      border-width: 0px;
      left: 79px;
      top: 94px;
      width: 90px;
      height: 28px;
      text-align: right;
    }

    .form-control {
      left: 0px;
      top: 0px;
      width: 360px;
      height: 30px;
      font-family: 'Arial Normal', 'Arial';
      font-weight: 400;
      font-style: normal;
      font-size: 13px;
      text-decoration: none;
      text-align: left;
    }

    .container-param {
      overflow-y: auto;
      overflow-x: hidden;
      padding-top: 20px;
      padding-bottom: 10px;
      margin-left: 20px;
      margin-top: 20px;
      border: 1px solid rgba(188, 188, 188, 1);
    }

    .control-group-height {
      height: 60px;
      padding-top: 5px;
    }

    .text-color {
      color: #A1A1A1;
    }
    .margin-left-15{
      margin-left: 15px;
    }
    .padding-top-8 {
      padding-top: 8px;
    }
    .btn{
      padding: 4px 12px;
    }
    /* input[type="text"], input[type="number"],
    select {
      height: 30px;
    } */

    /* .button-primary,.button-primary-flat {
      background-color: #1B9AF7;
      border-color: #1B9AF7;
      background-image: -moz-linear-gradient(top, #1B9AF7, #1B9AF7);
      background-image: -ms-linear-gradient(top, #1B9AF7, #1B9AF7);
      background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#1B9AF7), to(#1B9AF7));
      background-image: -webkit-linear-gradient(top, #1B9AF7, #1B9AF7);
      background-image: -o-linear-gradient(top, #1B9AF7, #1B9AF7);
      background-image: linear-gradient(top, #1B9AF7, #1B9AF7);
      background-repeat: repeat-x;
      filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#1B9AF7', endColorstr='#1B9AF7', GradientType=0);
      border-color: #1B9AF7 #1B9AF7 #1B9AF7;
      border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
      border-radius: 5px;
    }

    .button-primary:hover,.button-primary:active,.button-primary.active,.button-primary.disabled {
      background-color: #1B9AF7;
    }
    .button-primary[disabled] {
      background-color: #1B9AF7;
    }
    .button-primary:active,.button-primary.active {
      background-color: #1B9AF7;
    } */
    .preview {
      position: relative;
      background-repeat: no-repeat;
      background-size: cover;
    }
    .preview img{
      width: 5rem;
      height: 5rem;
    }
    #preview{
      width: 2.56rem;
      height: 2.56rem;
      position: relative;
      background-image: url(../u1907.png);
      background-repeat: no-repeat;
      background-size: cover;
    }
    #file{
      width: 100%;
      height: 100%;
      opacity: 0;
      position: absolute;
      left: 0;
      top: 0;
      cursor: pointer;
      z-index: 5;
    }
    .display-inline{
      display: inline-block;
    }
    .display-none{
      display: none;
    }
  </style>
</head>


<body>
  <div class="container">
    <div>
      <div class="container-title"><span>&nbsp;系统管理&gt;系统参数</span></div>
      <div class="title-border"></div>
    </div>

   <div>
    <form id="form_company" class="form-horizontal" method="POST" target="company_iframe" aria-disabled="false" action=""
      aria-pressed="false">
      <div class="container-param col-sm-12">
        <div class="row">
          <div class="col-sm-8">
            <label class="col-sm-3 control-label">企业名称:</label>
            <div class="col-sm-9">
              <input id="company_name" name="company_name" type="text" class="form-control" value="{{params_dict.enterprise_info.enterprise_name}}">
            </div>
          </div>
          <div class="col-sm-4"></div>
        </div>
        <div class="row padding-top-8">
          <div class="col-sm-8">
            <label class="col-sm-3 control-label">企业全宗号:</label>
            <div class="col-sm-9">
              <input name="company_number" type="text" class="form-control" data-rules="{required:true}"
                aria-disabled="false" aria-pressed="false" value="{{params_dict.enterprise_info.enterprise_number}}">
            </div>
          </div>
          <div class="col-sm-4">
            <button type="submit" class="btn btn-primary margin-left-15">保存</button>
          </div>
        </div>
      </div>
    </form>

    <form id="form_site_logo" class="form-horizontal" method="POST" action="" enctype="multipart/form-data">
      <div class="container-param col-sm-12">
        <div class="row">
          <div class="col-sm-8">
            <label class="col-sm-3 control-label">站点名称:</label>
            <div class="col-sm-9">
                <input name="site_name" type="text" class="form-control" value="{{params_dict.station_info.station_name}}">
            </div>
          </div>
          <div class="col-sm-4"></div>
        </div>
        <div class="row control-group-height padding-top-8">
          <div class="col-sm-8">
            <label class="col-sm-3 control-label">LOGO:</label>
            <div class="col-sm-9">
              <div id="imgUrl" class="preview imgUrl display-none">
                <img id="img" src="" alt="" click="againLogo()">
              </div>
              <div id="preview">
                <input type="file" accept="image/*" id="file" value="{{params_dict.station_info.logo}}" />
                <input type="text"  id="aaa" value="{{params_dict.station_info.logo}}" />
              </div>
            </div>
          </div>
          <div class="col-sm-4">
            <button type="submit" class="btn btn-primary margin-left-15">保存</button>
          </div>
        </div>
      </div>
    </form>


    <form id="form_file_type" class="form-horizontal" method="POST" aria-disabled="false" action="" aria-pressed="false">
      <div class="container-param col-sm-12">
        <div class="row">
          <div class="col-sm-8">
            <label class="col-sm-3 control-label">文件上传类型：</label>
            <div class="col-sm-9">
              <input name="file_limit" class="padding-top-8" type="checkbox"  value=""> 不限制
            </div>
          </div>
          <div class="col-sm-4"></div>
        </div>
        <div class="row">
          <div class="col-sm-8">
            <label class="col-sm-3 control-label">&nbsp;</label>
            <div class="col-sm-9">
              <textarea name="file_type" class="form-control" rows="3"  >{{params_dict.file_info.upload_type}}</textarea>
            </div>
          </div>
          <div class="col-sm-4">
            <button type="submit" class="btn btn-primary margin-left-15">保存</button>
          </div>
        </div>
      </div>
    </form>
        

    <form id="form_storage" class="form-horizontal" method="POST" aria-disabled="false" action="" aria-pressed="false">
      <div class="container-param col-sm-12">
        <div class="row">
          <div class="col-sm-8">
            <label class="col-sm-3 control-label">存储设置：</label>
            <div class="col-sm-9">
              <input name="storage_limit" type="number" min="0" class="form-control" value="{{params_dict.save_info.save_setting}}">
            </div>
          </div>
          <div class="col-sm-4"></div>
        </div>
        <div class="row">
          <div class="col-sm-8">
            <label class="col-sm-3 control-label">&nbsp;</label>
            <div class="col-sm-9">
              <span class="text-color">最大可上传的文件大小（单位M, 0表示不限制）</span>
            </div>
          </div>
          <div class="col-sm-4">
            <button type="submit" class="btn btn-primary margin-left-15 margin-left-15">保存</button>
          </div>
        </div>
      </div>
    </form>
   </div>
  </div>
  <!--<script type="text/javascript" src="../assets/js/jquery.min.js"></script>-->
  <!--<script type="text/javascript" src="../bootstrap/js/bootstrap.min.js"></script>-->
  <!--<script type="text/javascript" src="../assets/js/prettify.js"></script>-->
  <!--<script type="text/javascript">-->

  <script type="text/javascript" src="/static/assets/js/jquery.min.js"></script>
  <script type="text/javascript" src="/static/bootstrap/js/bootstrap.min.js"></script>
  <script type="text/javascript" src="/static/assets/js/prettify.js"></script>
  <script type="text/javascript">

    $(function () {
      var preview = document.querySelector('#preview');
      var eleFile = document.querySelector('#file');
      //获取系统设置参数
      getFormData();
      function getFormData() {
        // $.ajax({
        //   type: 'POST',
        //   url: '',
        //   dataType: 'json',
        //   success: function(resp){
      /*  $("input[name='company_name']").val("中国人");
        $("input[name='company_number']").val("企业全宗号");



        $("input[name='site_name']").val("站点名称");
        //处理返回的图片路径展示到页面上
        var getLogoUrl = "../assets/img/123.jpg";
        if(getLogoUrl){
          $('#preview').addClass('display-none');
          $('#imgUrl').removeClass('display-none');
          $('#imgUrl').addClass('display-inline');
          $("#img").attr("src", getLogoUrl);
        }else{
          $('#preview').addClass('display-inline');
          $("#imgUrl[img]").removeAttr("src");
          $('#imgUrl').addClass('display-none');
        }
        
        $("input[name='file_limit']").prop("checked", "checked");
        $("textarea[name='file_type']").val("doc,text");

        $("input[name='storage_limit']").val(10);*/
        //   },
        //   error: function(resp){
        //     console.log("获取系统参数失败");
        //   }
        // });
      }
      $("#img").click(function(){
        $('#preview').removeClass('display-none');
        $('#preview').addClass('display-inline');
        $("#img").attr("src", "");
        $('#imgUrl').addClass('display-none');
      });
      //图片上传预览监听
      eleFile.addEventListener('change', function () {
        var file = this.files[0];
        // 确认选择的文件是图片                
        if (file.type.indexOf("image") == 0) {
          var reader = new FileReader();
          reader.readAsDataURL(file);
          reader.onload = function (e) {
            // 图片base64化
            var newUrl = this.result;
            preview.style.width = '5rem';
            preview.style.height = '5rem';
            preview.style.backgroundImage = 'url(' + newUrl + ')';
          };
        }
      });
      //数据提交
      $("#form_company").submit(function () {
            console.log("aaaaaaaaaaaaaaaaaa");
        var company_name = $("input[name='company_name']").val();
        var company_number = $("input[name='company_number']").val();
        var stage_info='{"enterprise_name":"'+company_name+'","enterprise_number":"'+company_number+'"}'
        var stage_name="enterprise_info"
          console.log(stage_info);
        if (company_name || company_number) {
          console.log("form_company提交");
           $.ajax({
            //几个参数需要注意一下
                type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: "/api/paramsSettings/edit/" ,//url
                data: {"stage_id":1,"stage_name":stage_name,"stage_info":stage_info},
                success: function (result) {
                    console.log(result);//打印服务端返回的数据(调试用)
                     if (result.resultCode == 200) {
                        alert("SUCCESS");
                    }
                },
                error : function() {
                    alert("异常！");
                }
            });
          return true;
        } else {
          console.log("阻止form_company表单提交");
          return false;/*阻止表单提交*/
        }
      });
      $("#form_site_logo").submit(function () {
          console.log("dddddddddddddddddd")
        var site_name = $("input[name='site_name']").val();
        var logo = $("input[name='logo']").val();
        var stage_info = '{"station_name":"' + site_name + '","loge":"' + logo + '"}'
        var stage_name="station_info"
        if (site_name || logo) {
          console.log("form_site_logo提交");
           $.ajax({
            //几个参数需要注意一下
                type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: "/api/paramsSettings/edit/" ,//url
                data: {"stage_id":2,"stage_name":stage_name,"stage_info":stage_info},
                success: function (result) {
                    console.log(result);//打印服务端返回的数据(调试用)
                },
                error : function() {
                    alert("异常！");
                }
            });
          return true;
        } else {
          console.log("阻止form_site_logo表单提交");
          return false;
        }
      });
      $("#form_file_type").submit(function () {
        var file_limit = $("input[name='file_limit']").val();
        var upload_type = $("textarea[name='file_type']").val();

        var stage_info='{"upload_type":"'+upload_type+'","no_limit":"'+file_limit+'"}'
        var stage_name="file_info"
        if (file_limit || upload_type ) {
          console.log("form_file_type提交");
           $.ajax({
            //几个参数需要注意一下
                type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: "/api/paramsSettings/edit/" ,//url
                data: {"stage_id":3,"stage_name":stage_name,"stage_info":stage_info},
                success: function (result) {
                    console.log(result);//打印服务端返回的数据(调试用)
                },
                error : function() {
                    alert("异常！");
                }
            });
          return true;
        } else {
          console.log("阻止form_file_type表单提交");
          return false;
        }
      });
      $("#form_storage").submit(function () {
        var storage_limit = $("input[name='storage_limit']").val();
        var stage_info = '{"save_setting":"'+storage_limit+'"}'
        var stage_name = "save_info"
        if (storage_limit) {
          console.log("form_storage表单提交");
           $.ajax({
            //几个参数需要注意一下
                type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: "/api/paramsSettings/edit/" ,//url
                data: {"stage_id":4,"stage_name":stage_name,"stage_info":stage_info},
                success: function (result) {
                    console.log(result);//打印服务端返回的数据(调试用)
                },
                error : function() {
                    alert("异常！");
                }
            });
          return true;
        } else {
          console.log("阻止form_storage表单提交");
          return false;
        }
      });

    });
  </script>

  <body>

</html>